Generally, in programming language processing systems and computer program executing systems, such as compilers and interpreters, a character string in source code written in a given programming language is represented as an array. The array has elements with primitive values of the character type, or the type that is equivalent to the character type. The character string is passed by reference using a pointer that points to the array in question.
For example, in the programming language C or C++, a character string is represented as an array of elements of the “char” type. The last element of the array may contain the null character “\0”. Similarly, in the Pascal programming language, a character string is represented as an array of elements of the “char” type as well. The first element of the array may contain the length of the character string. In addition, in programming language processing systems operating within a virtual machine, even when a character string is defined as a basic type, the character string is nevertheless represented in a similar format.
Although such representations provide for processing of character strings of variable lengths, such processing typically requires a new character string to be allocated within a memory space as reserved within a heap. (The heap is a common pool of memory that is available to a computer program.) This is because in most cases, the required memory space cannot be allocated within a stack because the character string has a variable length. (The stack may be considered to be a reserved amount of memory used for arithmetic calculations, local variables or to keep track of internal operations of a computer program.) This is problematic, because processing operations involving the heap are generally more computationally intensive than processing operations involving the stack, which means that string processing performance suffers.
By comparison, in relational databases for instance, a fixed-length character string type may be employed. That is, the length of a field record is fixed to realize high-speed data management. While specifying fixed-length character string types may be able to be employed in programming languages as well to avoid string processing performance degradation, numerous disadvantages result. First, the amount of space allocated to each string is the same, even if the string has a length that is smaller than the maximum allowed length. As such, memory is not utilized efficiently. Second, strings greater than the maximum allowed length cannot be specified and/or processed, which can be an undue constraint on writing source code in such a manner.
For these and other reasons, therefore, there is a need for the present invention.